package com.example.tianyidemo.controller;


import com.example.tianyidemo.pojo.Post;
import com.example.tianyidemo.pojo.Result;
import com.example.tianyidemo.pojo.User;
import com.example.tianyidemo.service.SelectUsersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//获取帖子信息（简略）
@Slf4j
@CrossOrigin//准许跨域请求
@RestController//包含@Controller（三层架构声明控制器）和@ResponseBody（转化json格式）
public class SelectUserController {
    @Autowired
    private SelectUsersService selectUsersService;
    @ResponseBody
    //    删除用户
    @DeleteMapping("/delectuser")
    public  Result delectuser(@RequestParam Integer userId){
        int buycarList = selectUsersService.delectuser(userId);
        return Result.success(buycarList);
    }
    @GetMapping("/getuser")
    public Result userListlist(){
        List<User> UserList = selectUsersService.getuserList();
        return Result.success(UserList);
    };
    @PostMapping("/selectuser")
    public Result Selectuser(@RequestParam String user_name) {
        System.out.println(111);
        List<User> userList = selectUsersService.Selectuser(user_name);
        return Result.success(userList);
    }
    @PostMapping("/selectpost")
    public Result selectpost(@RequestParam String user_name) {
        System.out.println(111);
        List<Post> userList = selectUsersService.Selectusers(user_name);
        return Result.success(userList);
    }
    }
